package com.njwb.day08;

import java.util.Date;

public class TestDate {
    public static void main(String[] args) throws InterruptedException {
        //日期
        //获得当前日期
        Date d=new Date();
        System.out.println(d);
        //获得当前时间的毫秒数
        long l=d.getTime();
        System.out.println(l);
        //还原成Date
        Date d2=new Date(l);
        System.out.println(d2);
        System.out.println("================");
        Date start=new Date();
        System.out.println(start);
        Thread.sleep(1000);//休眠1秒
        Date end=new Date();
        System.out.println(end);
                //判断end时间是否在start时间之后
        boolean b=end.after(start);
        System.out.println(b);
                //判断start时间是否在end时间之前
        b=start.before(end);
        System.out.println(b);
        System.out.println();
        Date now=new Date();
        //获得年月日
        int year=now.getYear();
        int month=now.getMonth();
        int day=now.getDate();
        System.out.println(year+1900);
        System.out.println(month+1);
        System.out.println(day);

    }
}
